from __future__ import with_statement
import sys
sys.path.append("/home/stefan/Documents/fydp/fydp-david/module-test/fydp-david/src")
import gdb
import audio_breakpoint



class SetAudioBreakPointCommand (gdb.Command):
    """Save the current breakpoints to a file.
This command takes a single argument, a file name.
The breakpoints can be restored using the 'source' command."""

    def __init__ (self):
        super (SetAudioBreakPointCommand, self).__init__ ("audio setbr",
                                                       gdb.COMMAND_SUPPORT,
                                                       gdb.COMPLETE_FILENAME)

    def invoke (self, arg, from_tty):
		print "Setting breakpoint at " + str(arg)
		pitch = input('Enter the pitch: ')
		volume = input('Enter the volume: ')
		duration = input('Enter the duration (in milliseconds) : ')
		channel = raw_input ('Enter channel: ') 
		bp = AudioBreakPoint(arg)
		bp.pitch = pitch
		bp.volume = volume
		bp.duration = max(duration, 600)
		bp.channel = channel
		print "audio break point set at"
		print arg
	

SetAudioBreakPointCommand ()
